<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}{% endblock %} - 烟蒂绿航站</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
    <style>
        body {
            background: linear-gradient(135deg, #43cea2 0%, #185a9d 100%);
            min-height: 100vh;
            position: relative;
        }

        .card {
            background-color: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border: none;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .navbar {
            background-color: rgba(33, 37, 41, 0.95) !important;
            backdrop-filter: blur(10px);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .container.mt-4 {
            position: relative;
            z-index: 1;
        }

        /* 添加一些动态背景元素 */
        .bg-circles {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            overflow: hidden;
            z-index: 0;
        }

        .bg-circles li {
            position: absolute;
            display: block;
            list-style: none;
            width: 20px;
            height: 20px;
            background: rgba(255, 255, 255, 0.2);
            animation: animate 25s linear infinite;
            bottom: -150px;
            border-radius: 50%;
        }

        @keyframes animate {
            0% {
                transform: translateY(0) rotate(0deg);
                opacity: 1;
                border-radius: 0;
            }
            100% {
                transform: translateY(-1000px) rotate(720deg);
                opacity: 0;
                border-radius: 50%;
            }
        }

        .nav-link.active {
            font-weight: bold;
            color: #fff !important;
            position: relative;
        }

        .nav-link.active::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 2px;
            background-color: #fff;
            animation: slideIn 0.3s ease-in-out;
        }

        @keyframes slideIn {
            from {
                transform: scaleX(0);
            }
            to {
                transform: scaleX(1);
            }
        }

        /* 添加铜牌颜色 */
        .bg-bronze {
            background-color: #CD7F32 !important;
            color: white !important;
        }
        
        /* 排行榜项目悬停效果 */
        .list-group-item-action:hover {
            transform: translateX(5px);
            transition: transform 0.2s ease-in-out;
        }
    </style>
</head>
<body>
    <!-- 添加动态背景元素 -->
    <ul class="bg-circles">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>

    <nav class="navbar navbar-expand-lg navbar-dark">
        <div class="container">
            <a class="navbar-brand" href="{{ url_for('dashboard') }}">烟蒂绿航站</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    {% if current_user.is_authenticated %}
                        {% set navigation_items = [
                            ('dashboard', '个人中心'),
                            ('products', '商品列表')
                        ] %}
                        {% for endpoint, label in navigation_items %}
                            <li class="nav-item {% if request.endpoint == endpoint %}order-first{% endif %}">
                                <a class="nav-link {% if request.endpoint == endpoint %}active{% endif %}" 
                                   href="{{ url_for(endpoint) }}">{{ label }}</a>
                            </li>
                        {% endfor %}
                    {% endif %}
                </ul>
                <ul class="navbar-nav ms-auto">
                    {% if current_user.is_authenticated %}
                        <li class="nav-item me-3">
                            <span class="nav-link">积分: {{ current_user.points }}</span>
                        </li>
                        <li class="nav-item me-3">
                            <a class="nav-link position-relative" href="{{ url_for('view_cart') }}">
                                <i class="bi bi-cart3"></i> 购物车
                                {% if cart_count and cart_count > 0 %}
                                <span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">
                                    {{ cart_count }}
                                </span>
                                {% endif %}
                            </a>
                        </li>
                        <li class="nav-item">
                            <div class="d-flex align-items-center">
                                <a href="{{ url_for('profile') }}" class="text-decoration-none">
                                    {% if current_user.avatar_data is not none %}
                                        <img src="{{ url_for('get_avatar', user_id=current_user.id) }}" 
                                             class="rounded-circle me-2" 
                                             alt="头像" 
                                             style="width: 32px; height: 32px; object-fit: cover;">
                                    {% else %}
                                        <img src="{{ url_for('static', filename=current_user.avatar) }}" 
                                             class="rounded-circle me-2" 
                                             alt="头像" 
                                             style="width: 32px; height: 32px; object-fit: cover;">
                                    {% endif %}
                                </a>
                                <a class="nav-link" href="{{ url_for('logout') }}">退出</a>
                            </div>
                        </li>
                    {% else %}
                        <li class="nav-item">
                            <a class="nav-link" href="{{ url_for('login') }}">登录</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ url_for('register') }}">注册</a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        {% with messages = get_flashed_messages() %}
            {% if messages %}
                {% for message in messages %}
                    <div class="alert alert-info alert-dismissible fade show auto-dismiss" role="alert">
                        {{ message }}
                        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                    </div>
                {% endfor %}
            {% endif %}
        {% endwith %}
        
        {% block content %}{% endblock %}
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // 为背景圆圈添加随机大小和位置
        document.querySelectorAll('.bg-circles li').forEach((circle, index) => {
            circle.style.left = Math.random() * 100 + 'vw';
            circle.style.width = Math.random() * 100 + 'px';
            circle.style.height = circle.style.width;
            circle.style.animationDelay = Math.random() * 5 + 's';
            circle.style.animationDuration = (Math.random() * 10 + 15) + 's';
        });

        // 自动消失的提示
        document.addEventListener('DOMContentLoaded', function() {
            const alerts = document.querySelectorAll('.alert.auto-dismiss');
            alerts.forEach(alert => {
                setTimeout(() => {
                    const bsAlert = new bootstrap.Alert(alert);
                    bsAlert.close();
                }, 2000);
            });
        });
    </script>
</body>
</html> 